package logic

import (
	"wms/dao/mysql"
	"wms/define"
	"wms/models"
)

// GetFuncList 获取功能列表
func GetFuncList(mc *define.MyClaims, fb *[]*models.FunctionBasic) error {
	tx, err := mysql.GetFuncBasicByRoleIdentity(mc.RoleIdentity, mc.IsAdmin)
	if err != nil {
		return err
	}

	if err := tx.Scan(fb).Error; err != nil {
		return err
	}

	return nil
}

func GetFuncListWithMenuIdentity(mc *define.MyClaims, fl *[]*define.FuncListReply) error {
	tx, err := mysql.GetFuncBasicWithMenuIdentityByRoleIdentity(mc.RoleIdentity, mc.IsAdmin)
	if err != nil {
		return err
	}
	if err := tx.Scan(fl).Error; err != nil {
		return err
	}
	return nil
}
